<?php
	session_start();

	if (!isset($_SESSION['login']) && !$_SESSION['login'] == true) {
		header ("Location: index.php");
	}
	
	if(isset($_GET['ID']) && isset($_GET['mID']))
	{
		include ("config.php");

		$IDdirect = $_GET['ID'];
		$ToUpdate = $_GET['mID'];
		$managername = $_POST['managername'];
		$manageremail = $_POST['manageremail'];

		$_SESSION['Popup'] = $managername;
		$_SESSION['MessageKey']="saved";
		
		$stmt = $con->prepare('UPDATE `User` SET `Name` =  ?,`Login` = ? WHERE `ID` = ?');
		$stmt->bind_param('ssi', $managername, $manageremail, $ToUpdate);
		$stmt->execute();
		
		mysqli_close($con);
		
		header ("Location: editCompany.php?ID=" . $IDdirect);
	}
	else
		header ("Location: listusers.php");
?>